/*
package com.zprmb.udzt.activity;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshScrollView;
import com.zprmb.udzt.BaseActivity;
import com.zprmb.udzt.MainActivity;
import com.zprmb.udzt.R;
import com.zprmb.udzt.adapter.ExpandableBaseAdapter;
import com.zprmb.udzt.bean.ExpandableBean;
import com.zprmb.udzt.util.Constant;
import com.zprmb.udzt.util.LogUtils;
import com.zprmb.udzt.util.ToJSON;
import com.zprmb.udzt.util.VolleryUtil;
import com.zprmb.udzt.util.VolleryUtil3;
import com.zprmb.udzt.view.NestedListView;
import com.zprmb.udzt.view.SystemBarTintManager;

import org.json.JSONObject;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;


*/
/**
 * 项目列表
 *
 * @author shenshao
 *//*


public class ProductActivity_newBeifen extends BaseActivity implements OnClickListener, PullToRefreshBase.OnRefreshListener2<ScrollView> {

    //网络空图片
    private ImageView iv_v4_nonetwork1;
    PullToRefreshScrollView sv;
    private ExpandableBaseAdapter adapter;
    private int scrolledX, scrolledY;
    private List<ExpandableBean> list = new ArrayList<ExpandableBean>();

    DecimalFormat df = new DecimalFormat("###0.00");
    DecimalFormat df2 = new DecimalFormat("###0.0");

    NestedListView lv;

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();

//        BbtApplication.getInstance().removeActvity(this);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.product_activity);
//        BbtApplication.getInstance().addActvity(this);
//		initSystemBar(this);
        iv_v4_nonetwork1 = (ImageView) findViewById(R.id.iv_v4_nonetwork1);
        setImmersionStatus();
        sv = (PullToRefreshScrollView) findViewById(R.id.home_sv);

       */
/* sv.getRefreshableView().setChildIndicator(null);
        Drawable drawable = getResources().getDrawable(R.color.black);
         expandableListView.getRefreshableView().setChildDivider(drawable);
       *//*

        sv.setOnRefreshListener(this);
        sv.getLoadingLayoutProxy().setPullLabel("下拉可刷新");
        sv.getLoadingLayoutProxy().setRefreshingLabel("智慧投资 更优一点");
        sv.getLoadingLayoutProxy().setReleaseLabel("松开即刷新");
        lv = (NestedListView) findViewById(R.id.lv);
//		sv.getRefreshableView().addFooterView(getFooter(),null,false);
     */
/*   sv.getRefreshableView().setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

            @Override
            public boolean onGroupClick(ExpandableListView parent, View v,
                                        int groupPosition, long id) {
                // TODO Auto-generated method stub
                return true;
            }
        });*//*


       */
/* expandableListView.getRefreshableView().setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

            @Override
            public boolean onChildClick(ExpandableListView parent, View v,
                                        int groupPosition, int childPosition, long id) {
                // TODO Auto-generated method stub
//			Intent intent=new Intent(getActivity(),V6DetailsActivity.class);
                Intent intent = new Intent(ProductActivity.this, V6DetailsActivity.class);
                intent.putExtra("name", list.get(groupPosition).getList().get(childPosition).getProductName());
                intent.putExtra("type", list.get(groupPosition).getList().get(childPosition).getProductType());
                intent.putExtra("id", list.get(groupPosition).getList().get(childPosition).getLoanId());
                startActivityForResult(intent, 1);
                return false;
            }
        });*//*


        iv_v4_nonetwork1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                initData(true);
            }
        });
        if (!network()) {
            sv.setVisibility(View.GONE);
            iv_v4_nonetwork1.setVisibility(View.VISIBLE);
        } else {
            sv.setVisibility(View.VISIBLE);
            iv_v4_nonetwork1.setVisibility(View.GONE);
            initData(true);
        }
    }

    private void setImmersionStatus() {
        if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            // 透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            // 透明导航栏
            //getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        if (!network()) {
            sv.setVisibility(View.GONE);
            iv_v4_nonetwork1.setVisibility(View.VISIBLE);
        } else if (list.isEmpty()) {
            initData(true);
        } else {

        }
    }

    private void initData2(boolean isShow) {

        VolleryUtil3 volleryUtil = new VolleryUtil3() {

            @Override
            public void onUpDate(JSONObject jsonObject) {
                // TODO Auto-generated method stub
                LogUtils.e(ProductActivity_newBeifen.this, jsonObject.toString());
                ToJSON.initData2(jsonObject.toString(), "xindingqi");
                sv.setVisibility(View.VISIBLE);
                iv_v4_nonetwork1.setVisibility(View.GONE);
                Gson gson = new Gson();
                if (!jsonObject.optString("data").equals("null")) {
                    list = gson.fromJson(jsonObject.optString("data"),
                            new TypeToken<ArrayList<ExpandableBean>>() {
                            }.getType());
                }

                if (list.get(0) == null || list.get(0).getList() == null) {
                    sv.setVisibility(View.GONE);
                    iv_v4_nonetwork1.setVisibility(View.VISIBLE);
                } else {

                    if (list.get(0).getList().size() >= 1) {

                        adapter = new ExpandableBaseAdapter(ProductActivity_newBeifen.this, list);
                        lv.setAdapter(adapter);
                        adapter.notifyDataSetChanged();

                        */
/*for (int i = 0; i < list.size(); i++) {
                            expandableListView.getRefreshableView().expandGroup(i);
                        }*//*

                    }
                }


            }

            @Override
            public void onError() {
                // TODO Auto-generated method stub
                sv.setVisibility(View.GONE);
                iv_v4_nonetwork1.setVisibility(View.VISIBLE);
                Toast.makeText(ProductActivity_newBeifen.this, "请求失败   请检查网络设置", 2000).show();
            }
        };
        volleryUtil.setShow(isShow);
        volleryUtil.setRequestMethod(0);
//		volleryUtil.execute(getActivity(), Constant.URL
//				+ "api/v5/list/uplanList", "");
        volleryUtil.execute(ProductActivity_newBeifen.this, Constant.URL
                + "api/v6/render/productList", "");
//		Log.e("Uplan", Constant.URL + "api/v5/list/uplanList");

    }


    private void initData(boolean isShow) {

        VolleryUtil volleryUtil = new VolleryUtil() {

            @Override
            public void onUpDate(JSONObject jsonObject) {
                // TODO Auto-generated method stub
                LogUtils.e(ProductActivity_newBeifen.this, jsonObject.toString());
                ToJSON.initData2(jsonObject.toString(), "xindingqi");
                sv.setVisibility(View.VISIBLE);
                iv_v4_nonetwork1.setVisibility(View.GONE);
                Gson gson = new Gson();
                if (!jsonObject.optString("data").equals("null")) {
                    list = gson.fromJson(jsonObject.optString("data"),
                            new TypeToken<ArrayList<ExpandableBean>>() {
                            }.getType());
                }

                if (list.get(0) == null || list.get(0).getList() == null) {
                    sv.setVisibility(View.GONE);
                    iv_v4_nonetwork1.setVisibility(View.VISIBLE);
                } else {

                    if (list.get(0).getList().size() >= 1) {

                        adapter = new ExpandableBaseAdapter(ProductActivity_newBeifen.this, list);
                        lv.setAdapter(adapter);
                        adapter.notifyDataSetChanged();
*/
/*
                        for (int i = 0; i < list.size(); i++) {
                            expandableListView.getRefreshableView().expandGroup(i);
                        }*//*

                    }
                }


            }

            @Override
            public void onError() {
                // TODO Auto-generated method stub
                sv.setVisibility(View.GONE);
                iv_v4_nonetwork1.setVisibility(View.VISIBLE);
                Toast.makeText(ProductActivity_newBeifen.this, "请求失败   请检查网络设置", 2000).show();
            }
        };
        volleryUtil.setShow(isShow);
        volleryUtil.setRequestMethod(0);
//		volleryUtil.execute(getActivity(), Constant.URL
//				+ "api/v5/list/uplanList", "");
        volleryUtil.execute(ProductActivity_newBeifen.this, Constant.URL
                + "api/v6/render/productList", "");
//		Log.e("Uplan", Constant.URL + "api/v5/list/uplanList");

    }

  */
/*  public static ExpandableFragment newInstance(int position, String string) {
        ExpandableFragment uf = new ExpandableFragment();
        return uf;
    }*//*


    Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            if (!network()) {
                sv.setVisibility(View.GONE);
                iv_v4_nonetwork1.setVisibility(View.VISIBLE);
            } else {
                sv.setVisibility(View.VISIBLE);
                iv_v4_nonetwork1.setVisibility(View.GONE);
                list.clear();
                initData2(true);
            }


            sv.onRefreshComplete();
//				}
//			}, 600);
//
        }

        ;
    };

    @Override
    public void onPullDownToRefresh(
            PullToRefreshBase<ScrollView> refreshView) {
        // TODO Auto-generated method stub
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                handler.sendEmptyMessage(1);
            }
        }, 2000);

    }

    @Override
    public void onPullUpToRefresh(
            PullToRefreshBase<ScrollView> refreshView) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void onActivityResult(int arg0, int arg1, Intent arg2) {
        // TODO Auto-generated method stub
        super.onActivityResult(arg0, arg1, arg2);
        if (arg1 == 5) {
            MainActivity.newInstance().setCurrentTabByTag("tab_tag_zhanghu");
        }
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        return false;
    }


    public static void initSystemBar(Activity activity) {
        if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            setTranslucentStatus(activity, true);
        }
        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        tintManager.setStatusBarTintEnabled(true);
        //使用颜色资源

    }

    @TargetApi(19)
    private static void setTranslucentStatus(Activity activity, boolean on) {
        Window win = activity.getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }


    @Override
    public void onClick(View v) {

    }
}
*/
